<template>
	<el-header>
		<div style="display: flex; align-items: center;">
			<div class="flexible_model">
				<i class="el-icon-s-fold flexible" v-show="!collapse" @click="collapse = !collapse"></i>
				<i class="el-icon-s-unfold flexible" v-show="collapse" @click="collapse = !collapse"></i>
			</div>

			<el-breadcrumb>
				<el-breadcrumb-item v-for="(data, index) in breadcrumbs" :key="index" :to="data.path">{{data.name}}</el-breadcrumb-item>
			</el-breadcrumb>
		</div>
		<div class="header_right">
			<div style="cursor: pointer;" @click="openDrawer">
				<i class="icon-tools"></i>
			</div>
			<div>
				管理员
			</div>
		</div>
	</el-header>
</template>

<script>
	export default {
		data() {
			return {
				collapse: false,
				breadcrumbs: []
			};
		},

		watch: {
			collapse(value) {
				this.$pubsub.publish('collapse', value)
			}
		},

		mounted() {
			this.$pubsub.subscribe('breadcrumb', (msg, value) => {
				this.breadcrumbs = value
			})
		},

		methods: {
			openDrawer(){
				this.$pubsub.publish('openDrawer')
			}
		},

		beforeDestroy() {
			this.$pubsub.unsubscribe('breadcrumb')
		}

	}
</script>

<style>
	.el-header {
		height: 56px !important;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		box-shadow: 0 2px 2px #CCCCCC;
		background-color: white;
	}
</style>

<style scoped>
	.flexible {
		font-size: 28px;
		cursor: pointer;
		color: #444444;
		margin-right: 20px;
	}
	
	.header_right{
		display: flex; 
		align-items: center; 
		height: 100%;
	}
	.header_right>div{
		display: flex;
		align-items: center;
		padding: 0 10px;
		height: 100%;
	}
	.header_right i{
		font-size: 26px;
	}
</style>
